home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / artemis1 / src / cmdline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-08  |  2.2 KB  |  125 lines

  1. /*
  2.     ARTemis (Graphic Editor for FM-TOWNS)
  3.     (c) MATSUUCHI Ryosuke 1992,1993,1994,1995
  4.  
  5.     cmdline.c
  6.  
  7.     「ライン」コマンド
  8. */
  9.  
  10.  
  11. #include "ge.h"
  12. #include "imageman.h"
  13. #include "dispman.h"
  14. #include "mask.h"
  15.  
  16. void commandLine_sub(int type)
  17. // type 0:line   1:boxfill
  18. {
  19.     int step = 0;
  20.     int x1,y1,x2,y2;
  21.     void drawcsr(int msx,int msy)
  22.     {
  23.         MOFF;
  24.         int tx,ty;
  25.         tx = DMimage_getx(msx);
  26.         ty = DMimage_gety(msy);
  27.         if (step==1)
  28.         {
  29.             if (type == 0)
  30.                 EIMline(x1,y1,tx,ty,white,DrawXOR);
  31.             else
  32.                 EIMboxline(x1,y1,tx,ty,white,DrawXOR);
  33.         }
  34.         MON;
  35.     }
  36.     for(;;)
  37.     {
  38.         int prex,prey;
  39.         DMdispcsr(ms.x,ms.y);
  40.         drawcsr((prex=ms.x),(prey=ms.y));
  41.         do
  42.         {
  43.             ms_get(&ms);
  44.         } while (   ms.dx==0 && ms.dy==0 && ms.btn1==OFF && ms.btn2==OFF
  45.                  && key_chk()==0);
  46.         DMerasecsr();
  47.         drawcsr(prex,prey);            // 消去
  48.         scrollForCsr(1,1);
  49.         if (ms.btn1==OFFON)
  50.         {
  51.             if (step==0)             // 始点指定
  52.             {
  53.                 step=1;
  54.                 x1=DMimage_getx(ms.x);
  55.                 y1=DMimage_gety(ms.y);
  56.             }
  57.             else if (step==1)         // 終点指定
  58.             {
  59.                 EIMbackup();
  60.                 x2=DMimage_getx(ms.x), y2=DMimage_gety(ms.y);
  61.                 if (type == 0)
  62.                 {
  63.                     if (!ryosuke)
  64.                         lineWithPen(x1,y1,x2,y2,forecol,getcurpen(),YES);
  65.                     else
  66.                         aaline(x1,y1,x2,y2,forecol,getcurpen(),256);
  67.                 }
  68.                 else
  69.                     EIMboxfill(x1,y1,x2,y2,forecol,blkop);
  70.                 if (type == 0)
  71.                     x1=x2, y1=y2;
  72.                 else
  73.                     step=0;
  74.             }
  75.         }
  76.         if (ms.btn2==OFFON)
  77.         {
  78.             if (step==0)
  79.                 break;
  80.             else if (step==1)
  81.                 step=0;
  82.         }
  83.     }
  84. }
  85.  
  86.  
  87. void commandLine()
  88. {
  89.     commandLine_sub(0);
  90. }
  91.  
  92.  
  93. void commandBoxfill()
  94. {
  95.     for (;;)
  96.     {
  97.         if (area_input(AREA_BOX) != 0)
  98.             break;
  99.         EIMbackup();
  100.         int ax1,ay1,ax2,ay2;
  101.         area_getboundxy(&ax1,&ay1,&ax2,&ay2);
  102.         int x,y,mix;
  103.         mix = getmixrate();
  104.         ax1 = _lim(ax1, 0, EIMgetxsize());
  105.         ax2 = _lim(ax2, 0, EIMgetxsize());
  106.         ay1 = _lim(ay1, 0, EIMgetysize());
  107.         ay2 = _lim(ay2, 0, EIMgetysize());
  108.         for (y=ay1; y<=ay2; y++)
  109.         {
  110.             x = ax1 + area_chkxylen(ax1,ax2,y,YES);
  111.             while (x<=ax2)
  112.             {
  113.                 int l;
  114.                 if ((l = area_chkxylen(x,ax2,y,NO)) == 0)
  115.                     break;
  116.                 EIMgrayhline(x,x+l-1,y,forecol,mix,NO);
  117.                 x += l + area_chkxylen(x+l,ax2,y,YES);
  118.             }
  119.         }
  120.     }
  121. }
  122.  
  123.  
  124. /* end of cmdline.c */
  125.